package cn.javano.guava.learn;

import java.util.ArrayList;
import java.util.List;

import org.junit.Test;

import com.google.common.base.Joiner;
import com.google.common.base.Splitter;

/**
 * Guava String
 * 
 * @author lengleng
 * @date 2017年1月1日
 */
public class LearnStringUtil {
	/**
	 * 连接器[Joiner]
	 */
	@Test
	public void testJoin() {
		Joiner joiner = Joiner.on(";").skipNulls();
		System.out.println(joiner.join("a", null, "b"));

		List<String> ids = new ArrayList<String>();
		ids.add("1");
		ids.add("2");
		ids.add("3");
		ids.add("4");
		System.out.println(joiner.join(ids));
	}

	/**
	 * 拆分器[Splitter]
	 */
	@Test
	public void testSplitter() {
		Splitter splitter = Splitter.on(",").omitEmptyStrings();
		System.out.println(splitter.split("1,2,32,,1,5.0"));
	}
}
